fix(codemodel-foundation): marshal AnnotationValue.Value variants as real registered types#116
Merged
Merged
Conversation
…real registered types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AnnotationValue.Value(Literal,ClassRef,EnumConstant,Nested,Array) was marshalled through hand-rolledtoValue/fromValuehelpers that converted each variant to a rawObjectfor serialization. The conversion was asymmetric:ClassRefserialized to a bareTypeNameandEnumConstantserialized to a formatted"Type.CONSTANT"string, but the deserialize direction (toValue) had no matching cases for either, so both silently came back as aValue.Literalafter an unmarshal, losing their real type and, forEnumConstant, the type name and constant name as separate fields.Each
Valuevariant is now its own registered marshalled record, using@Unmarshal/@Marshalmethods andMarshalling.register, the same patternPersonRecordalready demonstrates inbase-marshalling's own test suite for a plain record with noTrait/Compositeinvolved.AnnotationValueitself now marshalsvalueas a plainMarshalled<Value>instead of routing through the raw-Objecthelpers, which are removed entirely.The bug was never caught because the only marshalling round-trip test touching
AnnotationValue(MarshallingTests#shouldMarshallAndTransportAndUnmarshallAnnotationTypeUsage) only ever exercisedValue.Literal, the one variant where the raw-Objectround-trip happened to work. Added dedicated round-trip tests for the other four variants.